package com.tidc.match.rabbit.service;
import com.tidc.match.rabbit.dto.ParamReq;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

@Service
public class PomitDirectMessageService {
	@Value("${rabbit.direct.key}")
	private String rabbitDirectKey;
	@Value("${rabbit.direct.exchange}")
	private String rabbitDirectExchange;

	@Autowired
	AmqpTemplate amqpTemplate;

	public void sendMessage(ParamReq paramReq){
//		这里的amqpTemplate是Spring自动生成的bean。消息的发送指定了rabbitDirectExchange、指定了rabbitDirectKey。
//		将消息发送到directExchange里路由键是spring。key。direct
		amqpTemplate.convertAndSend(rabbitDirectExchange,rabbitDirectKey,paramReq);
	}
}